function formatlink(value,row,index){
	var tn='';
	var id = row.id;
	var filename=row.fileName;
	tn=tn+="<span ><a href='javascript:void(0);' id='downloadfile1' style='color:black' onclick=downloadFile('"+id+"')>";
	tn=tn+=filename+"</a></span>";
	return tn;
}

function formatFile(value,row,index){ 
	var btn='';
	var id = row.id;//附件id
	var rowIndex=$('#attachment').datagrid('getRowIndex',row);
	btn=btn+='<span ><a href="#"  style="color:#FF0000" onclick="deleteFile(\''+id+'\',\''+rowIndex+'\');">删除</a></span>';
	return btn;

} 

/**
 * 附件下载
 * @param fileid
 */
function downloadFile(fileid){
	$.messager.confirm('提示', '确定下载?', function(data){
		if(data){
			window.location.href=ctx+ "/download?id="+fileid;
		}else{
			onload();
		}
	});
}

/**
 * 删除附件
 * @param id
 * @param rowIndex
 */
function deleteFile(id,rowIndex){
	$.messager.confirm('提示', '确定删除?', function(r){
        if (r){
       	 $.ajax({
      	        url : ctx+"/delete",
      	        data : {id:id},
      	        dataType : 'json',
      	        type : 'post',
      	        success : function (data) {
      	        	if(!showMsg(data,"删除成功")){
      					return;
      				}
      	        	$('#attachment').datagrid('deleteRow',rowIndex);
      	        }
      	    });
        }
    });
		
}